<?php
namespace common\records;
use Yii;
use yii\db\ActiveRecord;

class PowerRule extends ActiveRecord
{
    /**
    ** @return string 返回该AR类关联的数据表名
    **/
    public static function tableName()
    {
        return 'power_rule';
    }

    public function rules()
    {
        return [
            [['id','times_low', 'times_up', 'power', 'type'], 'integer'],
            [['timestamp'], 'string'],
            ];
    }

    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'times_low' => '次数下限',
            'times_up' => '次数上限',
            'power' => '娃娃机力度',
            'type' => '规则类型',
            'timestamp' => '规则创建时间',
            ];
    }
    public function beforeSave($insert)
    {
        if (parent::beforeSave($insert)) {
            if ($insert == true) {
                $this->timestamp = date('Y-m-d H:i:s');
            }
            return true;
        }
        return false;
    }
}
